<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with #game of life - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=%23game+of+life</link>
      <pubDate>Sun, 08 Aug 2021 20:27:35 +0000</pubDate>
         <description>Tagged with #game of life - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/tagged%23game+of+life/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>Game of Life - Can't find the error</title>
      <link>https://forum.processing.org/two/discussion/24696/game-of-life-can-t-find-the-error</link>
      <pubDate>Sun, 22 Oct 2017 23:23:10 +0000</pubDate>
      <dc:creator>DerBlaue</dc:creator>
      <guid isPermaLink="false">24696@/two/discussions</guid>
      <description><![CDATA[<p>As the title says I'm trying to program "Conways Game Of Life" but the cells don't behave as they should. I can't find my mistake. I hope one of you can find it :)</p>

<p>Seems like the code is too long so I made a pdf: <a rel="nofollow" href="https://drive.google.com/file/d/0B9pKdSOwgbtydjN1aU03TGQtSUk/view?usp=sharing">https://drive.google.com/file/d/0B9pKdSOwgbtydjN1aU03TGQtSUk/view?usp=sharing</a></p>
]]></description>
   </item>
   <item>
      <title>Cannot read property '0' of undefined</title>
      <link>https://forum.processing.org/two/discussion/23165/cannot-read-property-0-of-undefined</link>
      <pubDate>Thu, 22 Jun 2017 08:23:20 +0000</pubDate>
      <dc:creator>cameronnichols</dc:creator>
      <guid isPermaLink="false">23165@/two/discussions</guid>
      <description><![CDATA[<p>I don't understand why I'm getting this error. I am attempting to make Conway's Game Of Life, and this requires a grid. So in the process of drawing the grid, it makes it to the last column, and 2nd row (index 1) and produces the error in the title. I don't understand why, I even put 'grid' in the console log and none of the elements were undefined.</p>

<pre><code>function Cell(i,j){
  this.r = j;
  this.c = i;
  this.x = this.c*res;
  this.y = this.r*res;
  this.state = floor(random(0,1)+.5);
  this.next;
  this.getNeighborhood = () =&gt; {
    let temp = [];
    for (let k = -1; k &lt;=1; k++){
      for (let l = -1; l &lt;= 1; l++){
        if (inRange(k,0,cols) &amp;&amp; inRange(l,0,rows)){
          temp.push(grid[this.c+k][this.r+l]);
        }
      }
    }
    return temp;
  }
  this.show = () =&gt; {
    stroke(0);
    fill(this.state*255);
    rect(this.x,this.y,res,res);
  }
}

function inRange(val,min,max){
  return (val&gt;=min&amp;&amp;val&lt;max)
}
</code></pre>

<p>Those two functions are in a separate file from the main sketch.</p>

<p>Here's the main sketch:</p>

<pre><code>var res = 10;
var cols;
var rows;
var grid;

function setup(){
  createCanvas(600,600);
  cols = floor(width/res);
  rows = floor(height/res);
  grid = new Array(cols);
  for (let i = 0; i &lt; grid.length; i++){
    grid[i] = new Array(rows);
    for (let j = 0; j &lt; grid[i].length; j++){
      grid[i][j] = new Cell(i,j);
    }
  }
}

function draw(){
  background(255);
  for (let i = 0; i &lt; grid.length; i++){
    for (let j = 0; j &lt; grid[i].length; j++){
      let cell = grid[i][j];
      cell.show();
      cell.next = computeState(cell);
      cell.state = cell.next;
      cell.show();
    }
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Specific neighbourhoods in the Game of Life</title>
      <link>https://forum.processing.org/two/discussion/22882/specific-neighbourhoods-in-the-game-of-life</link>
      <pubDate>Fri, 02 Jun 2017 21:46:42 +0000</pubDate>
      <dc:creator>HolyMoley</dc:creator>
      <guid isPermaLink="false">22882@/two/discussions</guid>
      <description><![CDATA[<p>tl;dr : I reset the variable to store the neighbours in everytime I checked a new neighbour.</p>

<p>I recently found processing and thought the Game of Life would be an easy first project.
But when I tried going from neighbourCount only, to saving neighbours in order -  in an Array - I stopped getting neighbourCounts bigger than one.</p>

<p>I know it is not needed to store the specific configuration of neighbours to make the Game of Life work, but I want to expand on the idea once I get this working.
Why am I not getting the right neighbourCount?
I know it's a lot, but I put in as many comments as possible to make it easier on the eyes.</p>

<pre><code>int interval = 1000;                         // time between iterations
int lastRecordedTime = 0;                    // timer

int cellSize = 5;                            // size of one Cell
int counterLocal;                            // variable for storing neighbourCount
int [] neighbourhood = {0,0,0,0,0,0,0,0};    // Array for storing neighbourhood configuration
int [][] cells;                              // 2D Cells Array
int [][] cellsBuffer;                        // 2D Buffer Array to work on while leaving cells[][] unharmed

float prob = 30;                             // probability of Cell being alive at setup

color alive = color(0, 0, 0);                // Alive color = black
color dead = color(255, 255, 255);           // Dead color = white




void setup() {
  size (200, 200);
  cells = new int [width/cellSize][height/cellSize];
  cellsBuffer = new int [width/cellSize][height/cellSize];
  stroke(48);
  noSmooth();

  for ( int x = 0; x &lt; width/cellSize; x++) {                // Randomize cells[][]
    for ( int y = 0; y &lt; height/cellSize; y++) {
      float state = random(100);
      if (state &gt; prob) {
        state = 0;
      } else {
        state = 1;
      }
      cells[x][y] = int(state);
    }
  }
  background(0);
} // end of setup()




void draw() {                                                // Loop through every cell in cells[][] and draw them according to their state
  for ( int x = 0; x &lt; width/cellSize; x++) {
    for ( int y = 0; y &lt; height/cellSize; y++) {
      if (cells[x][y] == 1) {
        fill(alive);
      } else {
        fill (dead);
      }
      rect (x*cellSize, y*cellSize, cellSize, cellSize);
    }
  }
  if (millis() - lastRecordedTime &gt; interval) {
    iteration();
    lastRecordedTime = millis();
  }
} // end of draw()





void iteration() {    
  for (int x = 0; x &lt; width/cellSize; x++) {                                       // copy cells Array to cellsBuffer
    for (int y = 0; y &lt; height/cellSize; y++) {
      cellsBuffer[x][y] = cells[x][y];
    }
  } 



  for (int x = 0; x &lt; width/cellSize; x++) {                                       // go through every cell
    for (int y = 0; y &lt; height/cellSize; y++) {

      String neighbourCode = "0,0,0,0,0,0,0,0";                                    // string used to encode neighbour positions    

      for (int xx=x-1; xx&lt;=x+1; xx++) {                                            // go through all neighbours of current Cell
        for (int yy=y-1; yy&lt;=y+1; yy++) {  

          if (((xx&gt;=0)&amp;&amp;(xx&lt;width/cellSize))&amp;&amp;((yy&gt;=0)&amp;&amp;(yy&lt;height/cellSize))) {   // Make sure you are not out of bounds
            //if (!((xx==x)&amp;&amp;(yy==y))) {                                           // Make sure to to check against self (not needed)

              int[] codeArray = int(split(neighbourCode, ","));                    // Split string into Array

              if ((x - xx == 1) &amp;&amp; (y - yy == 1)) {           //top left           //1. Check which neighbour you are (if, else if, else if...)
                if (cellsBuffer[xx][yy] == 1){
                codeArray[0] = 1;                                                  //2. if alive, set codeArray at corresponding index to 1
                }
              }

              else if ((x - xx == 0) &amp;&amp; (y - yy == 1)) {      //top mid
                if (cellsBuffer[xx][yy] == 1){
                codeArray[1] = 1;
                }
              }

              else if ((x - xx == -1) &amp;&amp; (y - yy == 1)) {     //top right
                if (cellsBuffer[xx][yy] == 1){
                codeArray[2] = 1;
                }
              }

              else if ((x - xx == 1) &amp;&amp; (y - yy == 0)) {       //mid left
                if (cellsBuffer[xx][yy] == 1){
                codeArray[3] = 1;
                }
              }

              else if ((x - xx == -1) &amp;&amp; (y - yy == 0)) {      //mid right
                if (cellsBuffer[xx][yy] == 1){
                codeArray[4] = 1;
                }
              }

              else if ((x - xx == 1) &amp;&amp; (y - yy == -1)) {      //bot left
                if (cellsBuffer[xx][yy] == 1){
                codeArray[5] = 1;
                }
              }

              else if ((x - xx == 0) &amp;&amp; (y - yy == -1)) {       //bot mid
                if (cellsBuffer[xx][yy] == 1){
                codeArray[6] = 1;
                }
              }

              else if ((x - xx == -1) &amp;&amp; (y - yy == -1)) {      //bot right
                if (cellsBuffer[xx][yy] == 1){
                codeArray[7] = 1;
                }
              }                                                 // finished making codeArray


              for (int n = 0; n &lt; codeArray.length; n++) {      // copy codeArray to public Array
                neighbourhood[n] = codeArray[n];
              }



              int neighbourCount = 0;
              for (int neighbourIndex = 0; neighbourIndex &lt; codeArray.length; neighbourIndex++) {      // Converting neighbourCode to neighbourCount
                if (codeArray[neighbourIndex] == 1) {
                  neighbourCount = neighbourCount + 1;
                }
               }                                                // end of Conversion
               counterLocal = neighbourCount;                   // copy neighbourCount to public int

            //} // end of self check (not needed)
          } // end of out of Bounds check
        } // end of for (yy++) loop
      } // end of for (xx++) loop





        if (cellsBuffer[x][y] == 1) {                                              // applying ruleset for the game of life and writing to cells Array
          if (counterLocal &lt; 2 || counterLocal &gt; 3) {
            cells [x][y] = 0;
          }
        } else {
          if (counterLocal == 3) {
            cells[x][y] = 1;
          }
        }



    } // end of for (y++) loop
  } // end of for (x++) loop
}  //end of iteration ()
</code></pre>

<p>If you're still reading this, you are my hero.</p>
]]></description>
   </item>
   <item>
      <title>Cellular automaton's rules storage</title>
      <link>https://forum.processing.org/two/discussion/21183/cellular-automaton-s-rules-storage</link>
      <pubDate>Sun, 05 Mar 2017 20:38:05 +0000</pubDate>
      <dc:creator>yaya671</dc:creator>
      <guid isPermaLink="false">21183@/two/discussions</guid>
      <description><![CDATA[<p>Hi, I am programming a orthogonal cellular automaton class (a kind of generalized <a rel="nofollow" href="https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life">Game of Life</a>). The basic principle is that at each generation, for each cell, we count the number of neighbors in each state and then use a list of rules indicating what state is gonna take that cell in function of the number of neighbors in each state and the cell's actual state.</p>

<p>My question is about how to stock and access the rules.</p>

<p>We have variables number S of states and N of neighbors (it doesn't change after automaton initialization), and I want to access a particular rule by giving the number of neighbors in each state and the cell's actual state.</p>

<p>So at first I thought to an array of size S (for the actual state) of emulated S-dimensional arrays of size N (N^S arrays).</p>

<p>For example, the rules of the Game of Life would look like that :</p>

<pre><code>{{
    0,0,0,0,0,0,0,0, 0,
    0,0,0,0,0,0,0, 0,0,
    0,0,0,0,0,0, 0,0,0,
    0,0,0,0,0, 1,0,0,0,
    0,0,0,0, 0,0,0,0,0,
    0,0,0, 0,0,0,0,0,0,
    0,0, 0,0,0,0,0,0,0,
    0, 0,0,0,0,0,0,0,0,
     0,0,0,0,0,0,0,0,0
  }, {
    0,0,0,0,0,0,0,0, 0,
    0,0,0,0,0,0,0, 0,0,
    0,0,0,0,0,0, 1,0,0,
    0,0,0,0,0, 1,0,0,0,
    0,0,0,0, 0,0,0,0,0,
    0,0,0, 0,0,0,0,0,0,
    0,0, 0,0,0,0,0,0,0,
    0, 0,0,0,0,0,0,0,0,
     0,0,0,0,0,0,0,0,0
  }}
</code></pre>

<p>As you see it's really not optimal.</p>

<p>Because numbers of neighbors in each state add up to N, there are only  (N + S - 1)! / (N! (S - 1)! elements used on the N^S in each sub array.</p>

<p>I run out of ideas, so I hope you might help find a better way to store my rules.</p>
]]></description>
   </item>
   <item>
      <title>Game of Lyfe &amp; Pictures</title>
      <link>https://forum.processing.org/two/discussion/20855/game-of-lyfe-pictures</link>
      <pubDate>Fri, 17 Feb 2017 17:14:50 +0000</pubDate>
      <dc:creator>semiprocoder</dc:creator>
      <guid isPermaLink="false">20855@/two/discussions</guid>
      <description><![CDATA[<p>So I recently stumbled upon game of life, and I can't use an already made program for that! So I decided to make my own version of conway's game of life, but I decided to play around with the settings. I can change the amount of living cells next to a dead one that are necessary to make it come alive, and I can change the "tolerance" of living cells, where they stay alive with a different amount of living cells. Then I added color by taking the amount of living cells adjacent in the previous generation. I also added walls that cannot support life no matter what. This is why I renamed my game to LYFE. I also plan to add a two player mode, but I have not done that yet.</p>

<p>I programmed this is eclipse, so I cannot really port it to open processing or anything(well I could, but I don't know javascript). Anyways, the github link has a zip of the source with some screenshots I was playing around with and it has a zip with a compiled jar of my code(Note: the settings are in, well, the settings folder, and should be mostly self explanatory, but if you have any questions, just ask!).
<a rel="nofollow" href="https://github.com/awesommee333/LYFE">https://github.com/awesommee333/LYFE</a></p>

<p>And here is a screenshot of something I made with this program:
<img src="https://forum.processing.org/two/uploads/imageupload/837/T4G7K1CIKRG6.png" alt="capture-000234SCALED" title="capture-000234SCALED" /></p>
]]></description>
   </item>
   <item>
      <title>Game of Life BUG</title>
      <link>https://forum.processing.org/two/discussion/20766/game-of-life-bug</link>
      <pubDate>Sun, 12 Feb 2017 22:24:18 +0000</pubDate>
      <dc:creator>niklaseeeee</dc:creator>
      <guid isPermaLink="false">20766@/two/discussions</guid>
      <description><![CDATA[<p>I dont know what is wrong but, my game of life looks very akward.</p>

<p>(My Code is shit but it works)</p>

<p>THE CODE IS BUGGY ON THE PROCESSINg WEBSITE SO I POSTED IT ON PASTEBIN
<a href="http://pastebin.com/zh5uupi3" target="_blank" rel="nofollow">http://pastebin.com/zh5uupi3</a>
<a href="http://pastebin.com/zh5uupi3" target="_blank" rel="nofollow">http://pastebin.com/zh5uupi3</a>
<a href="http://pastebin.com/zh5uupi3" target="_blank" rel="nofollow">http://pastebin.com/zh5uupi3</a></p>

<pre><code>// GameSize = 10x10
  int gameSize = 100;
  Cell[][] c = new Cell[gameSize][gameSize];
  int fr = 10;
  int frames = 0;

  boolean isDraving = true;

  void setup() {
    size(400, 400);
    frameRate(30);
    noStroke();

    // random cells are alive
    for (int x = 0; x &lt; gameSize; x++) {
      for (int y = 0; y &lt; gameSize; y++) {
        c[x][y] = new Cell();
        if (random(1)&lt; 0.05) {
          c[x][y].alive = true;
        }
      }
    }
  }

  void draw() {
    frames++;
    if (!isDraving) {
      if (frames % fr == 0) {
        for (int x = 0; x &lt; gameSize; x++) {
          for (int y = 0; y &lt; gameSize; y++) {

            // CALCULATE LIVING CELLES
            int lc = 0;
            try { // left upper
              if (c[x-1][y-1].alive == true) lc++;
            } 
            catch(Exception e) {
            }

            try { //  upper
              if (c[x][y-1].alive == true) lc++;
            } 
            catch(Exception e) {
            }

            try { // right upper
              if (c[x+1][y-1].alive == true) lc++;
            } 
            catch(Exception e) {
            }

            try { // left
              if (c[x-1][y].alive == true) lc++;
            } 
            catch(Exception e) {
            }

            try { // right
              if (c[x+1][y].alive == true) lc++;
            } 
            catch(Exception e) {
            }

            try { // left down
              if (c[x-1][y+1].alive == true) lc++;
            } 
            catch(Exception e) {
            }

            try { // down
              if (c[x][y-1].alive == true) lc++;
            } 
            catch(Exception e) {
            }

            try { // right down
              if (c[x+1][y+1].alive == true) lc++;
            } 
            catch(Exception e) {
            }

            if (lc &gt; 0) println(lc);
            c[x][y].calculate(lc);

            // DRAW CELLES
            if (c[x][y].alive) {
              fill(255);
            } else {
              fill(0);
            }
            rect(width/gameSize*x, height/gameSize*y, width/gameSize, height/gameSize);
          }
          if (keyPressed) isDraving = true;
        }
      }
    } else {

      if (mousePressed) {
        int mx = floor( mouseX /(width/gameSize));
        int my = floor( mouseY /(width/gameSize));

        c[mx][my].alive = true;
      }

      if (keyPressed) isDraving = false;

      for (int x = 0; x &lt; gameSize; x++) {
        for (int y = 0; y &lt; gameSize; y++) {
          // DRAW CELLES
          if (c[x][y].alive) {
            fill(255);
          } else {
            fill(0);
          }
          rect(width/gameSize*x, height/gameSize*y, width/gameSize, height/gameSize);
        }
      }
    }
  }


  class Cell {
    boolean alive;

    void calculate(int lN) {
      if (lN == 3 || lN == 2) {
        // NOTHING ;D
        alive = true;
        //println("ALIVE");
      }
      if (lN &lt; 2) {
        alive = false;
      }
      if (lN &gt; 3) {
        alive = false;
      }
    }
  }
</code></pre>
]]></description>
   </item>
   <item>
      <title>Conway's Game of Life logic isn't working properly?</title>
      <link>https://forum.processing.org/two/discussion/19879/conway-s-game-of-life-logic-isn-t-working-properly</link>
      <pubDate>Thu, 22 Dec 2016 07:08:57 +0000</pubDate>
      <dc:creator>TheApexTheater</dc:creator>
      <guid isPermaLink="false">19879@/two/discussions</guid>
      <description><![CDATA[<p>Hello! I'm trying to make a visualization of Conway's Game of Life, but as the title suggests, I'm having a small bug:</p>

<p>The logic I implemented to check how many "alive neighbors" a cell consistently gets the number of alive neighbors incorrect... Below is the code, with some sample output.</p>

<pre><code> final int SIZE = 5;
final int SCREEN_WIDTH = 500;
final int SCREEN_HEIGHT = 500;

final color ON = color(255, 255, 255);
final color OFF = color(0);

final int SQUARE_LENGTH = SCREEN_WIDTH/SIZE;

boolean [][] GOL_Grid = new boolean[SIZE][SIZE];

void setup()
{
  size(500, 500);
  background(200);
  println("BEFORE ASSIGNMENT");
  printGrid(GOL_Grid);

  //Attempting to make the "Blinker" oscillator (found on the wikipedia page for Conway's Game Of Life)
  GOL_Grid[1][2] = true;
  GOL_Grid[2][2] = true;
  GOL_Grid[3][2] = true;
    println("AFTER ASSIGNMENT");
  printGrid(GOL_Grid);

  GOL_Grid = updateGrid(GOL_Grid);
  println("AFTER UPDATING");
  printGrid(GOL_Grid);
}

void drawGrid(final boolean[][] grid)
{
  println("------------------------");
  for (int i = 0; i &lt; grid.length; i++)
  {
    int curr_Y = i*SQUARE_LENGTH;
    for (int j = 0; j &lt; grid[i].length; j++)
    {
      if (grid[i][j])
        print( "X\t");
      else
        print("-\t");
      int curr_X = j*SQUARE_LENGTH;
      stroke(255);
      if (grid[i][j])
        fill(ON); 
      else
        fill(OFF);

      rect(curr_X, curr_Y, SQUARE_LENGTH, SQUARE_LENGTH);
    }
    println();
  }
  println("------------------------");
}

/************
 (1) Any live cell with fewer than two live neighbours dies, as if caused by underpopulation.
 (2) Any live cell with two or three live neighbours lives on to the next generation.
 (3) Any live cell with more than three live neighbours dies, as if by overpopulation.
 (4) Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

 *************/
boolean updateCell(final boolean[][] grid, int row, int col)
{
  int neighborCount = 0;
  boolean isAlive = grid[row][col];

  for (int newRow = row-1; newRow &lt;= row+1; newRow++)
  {
    if (newRow &lt; 0 || newRow &gt;= SIZE) continue; //Bounds check

    for (int newCol = col-1; newCol &lt;= col+1; newCol++)
    {
      if (newCol &lt; 0 || newCol &gt;= SIZE) continue; //Bounds check

      if (row == newRow &amp;&amp; col == newCol) continue;
      if (grid[newRow][newCol] == true) //Checks if each neighbor is "alive"
        neighborCount++; //The current cell's alive/death state is based on how many of its neighbors are alive
    }
  }
  print(neighborCount + "\t"); //Prints how many neighbors there are, for debugging purposes
  boolean update = grid[row][col];

  if (neighborCount &lt; 2 || neighborCount &gt; 3)
    update = false; //Cell is dead;
  if (!grid[row][col] &amp;&amp; neighborCount == 3) 
    update = true;

  return update;
}

boolean[][] updateGrid(final boolean[][] grid)
{
println("NOW UPDATING GRID (Now showing how many alive neigbors a particular cell has): "); 
  boolean[][] grid_COPY = grid;
  for (int row = 0; row &lt; SIZE; row++) //Iterate through once per cell in the original grid
  {
    for (int col = 0; col &lt; SIZE; col++)
    {
      grid_COPY[row][col] = updateCell(grid, row, col);
    }
    println();
  }
  return grid_COPY;
}

void printGrid(boolean[][] grid)
{
  println("------------------------");
  for (int i = 0; i &lt; grid.length; i++)
  {
    int curr_Y = i*SQUARE_LENGTH;
    for (int j = 0; j &lt; grid[i].length; j++)
    {
      if (grid[i][j])
        print( "X\t");
      else
        print("-\t");
    }
    println();
  }
  println("------------------------");
}
</code></pre>

<p>I should mention that while debugging, I think the error lies in either the updateGrid or the updateCell functions</p>

<p>OUTPUT:</p>

<pre><code>BEFORE ASSIGNMENT
------------------------
-   -   -   -   -   
-   -   -   -   -   
-   -   -   -   -   
-   -   -   -   -   
-   -   -   -   -   
------------------------
AFTER ASSIGNMENT
------------------------
-   -   -   -   -   
-   -   X   -   -   
-   -   X   -   -   
-   -   X   -   -   
-   -   -   -   -   
------------------------
NOW UPDATING GRID (Now showing how many alive neighbors a particular cell has): 
0   1   1   1   0   
0   2   1   1   0   
0   2   1   1   0   
0   1   0   0   0   
0   0   0   0   0   
AFTER UPDATING
------------------------
-   -   -   -   -   
-   -   -   -   -   
-   -   -   -   -   
-   -   -   -   -   
-   -   -   -   -   
------------------------
</code></pre>
]]></description>
   </item>
   <item>
      <title>Second image doesnt dissapear</title>
      <link>https://forum.processing.org/two/discussion/18264/second-image-doesnt-dissapear</link>
      <pubDate>Fri, 23 Sep 2016 16:56:18 +0000</pubDate>
      <dc:creator>phaidon</dc:creator>
      <guid isPermaLink="false">18264@/two/discussions</guid>
      <description><![CDATA[<p>Hello,i have this code with two image appearing as instruction,the first appears and dissapears well,but the second image doesnt disappear,i want to be disappear after some seconds,but it doesnt work,i tried boolean,framecount,custom count.but it doesnt disappear.I think maybe the problem is the if tracking statement.</p>

<pre><code>import peasy.*;
import saito.objloader.*;
import spout.*;
import SimpleOpenNI.*;

//PrintWriter output;
OBJModel model ;
OBJModel Smodel ;
OBJModel tmpmodel ;

Spout spout;

SimpleOpenNI kinect;

PeasyCam cam;

float z=0;

float r;
float k;
int VertCount;
PVector[] Verts;
PVector[] locas;
PVector[] Bez;
PVector[] Bez2;
PVector Mouse;
PVector Mouse2;
PVector rightHand;
PVector convertedRightHand;
PVector leftHand;
PVector convertedLeftHand;
PVector rightShoulder;
PVector convertedRightShoulder;
PVector leftShoulder;
PVector convertedleftShoulder;
float rightHandZ;
float ConrightHandZ;
float leftHandZ;
float ConleftHandZ;

boolean Kin;

boolean Text1;
boolean Text2;

PImage img;
PImage img2;


int Tmeter=0;

int VECS = 800;


void setup()
{
  size(1920, 1440, P3D);

  //hypotenuse 2450

  frameRate(30);
  noStroke();

  kinect = new SimpleOpenNI(this);
  kinect.enableDepth();
  kinect.enableUser();

  //800*800--&gt;200,1920*1440--&gt;300
  model = new OBJModel(this, "Model2.obj", "absolute", TRIANGLES);
  model.enableDebug();
  model.scale(300);
  model.translateToCenter();


  Smodel = new OBJModel(this, "Model2.obj", "absolute", TRIANGLES);
  Smodel.enableDebug();
  Smodel.scale(300);
  Smodel.translateToCenter();


  tmpmodel = new OBJModel(this, "Model2.obj", "absolute", TRIANGLES);
  tmpmodel.enableDebug();
  tmpmodel.scale(300);
  tmpmodel.translateToCenter();

  //output = createWriter("positions.txt"); 

  cam = new PeasyCam(this, width/2, height/2, 0, 2610);
  //800*800 --&gt; cam 1600,1920*1440--&gt; cam 2610
  spout = new Spout(this);
  spout.createSender("Self kinect");

  img = loadImage("Text1.png");
  img2 = loadImage("Text2.png");
}



void draw()
{
  background(0);
  pointLight(255, 255, 255, 
  width/2, height/2, width*2);

  kinect.update();
  IntVector userList = new IntVector();
  kinect.getUsers(userList);

  int VertCount = model.getVertexCount ();
  Verts = new PVector[VertCount];
  locas = new PVector[VertCount];
  Bez = new PVector[VertCount];
  Bez2 = new PVector[VertCount];
  r =300;
  k = k + 0.01;



  PVector psVerts[] = new PVector[VECS];
  PVector psVerts2[]= new PVector[VECS];


  cam.setMouseControlled(false);

  if (userList.size() &lt;= 0) {
    Text1 = false;
    Text2= false;
    Tmeter=0;
  }

  if (userList.size() &gt; 0) {


    int userId = userList.get(0);
    Text1 = true;

    if ( kinect.isTrackingSkeleton(userId)) {



      Kin= true;


      Text1 = false;


      Text2=true;



      pushMatrix();
      translate(0, 0, 1255);
      //the hypotenuse

      image(img2, 0, 0);

      popMatrix();
      Tmeter+=1;


      if (Tmeter&gt;=10 ) {
        Text2=false;
        //print("ok");
        //print(Text2);
      }

      print(Tmeter);

      rightHand = new PVector();
      kinect.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_LEFT_HAND, rightHand);

      convertedRightHand = new PVector();
      kinect.convertRealWorldToProjective(rightHand, convertedRightHand);

      leftHand = new PVector();
      kinect.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_RIGHT_HAND, leftHand);

      convertedLeftHand = new PVector();
      kinect.convertRealWorldToProjective(leftHand, convertedLeftHand);


      rightShoulder = new PVector();
      kinect.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, rightShoulder);

      convertedRightShoulder = new PVector();
      kinect.convertRealWorldToProjective(rightShoulder, convertedRightShoulder);


      leftShoulder = new PVector();
      kinect.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, leftShoulder);

      convertedleftShoulder = new PVector();
      kinect.convertRealWorldToProjective(leftShoulder, convertedleftShoulder);






      rightHandZ =  map(rightHand.z, 5500, 7500, 1100, 1500);
      ConrightHandZ = map(rightHandZ, 1100, 1500, 0, 1440);

      leftHandZ =map(leftHand.z, 5500, 7500, 1100, 1500);
      ConleftHandZ = map(leftHandZ, 1100, 1500, 0, 1440);

      Mouse = new PVector(rightHand.x, -rightHand.y, z);
      Mouse2 = new PVector(leftHand.x, -leftHand.y, z);


      pushMatrix();
      translate(width/2, height/2, 0);



      pushMatrix();
      //-----------------HERE
      translate(Mouse2.x, Mouse2.y, Mouse2.z);
      //-------------AND HERE
      noFill();
      stroke(255);
      strokeWeight(3);
      box(r, r, 2450);
      popMatrix();



      pushMatrix();
      //-----------------HERE
      translate(Mouse.x, Mouse.y, Mouse.z);
      //-------------AND HERE
      noFill();
      stroke(255);
      strokeWeight(3);
      box(r, r, 2450);
      popMatrix();


      popMatrix();
    }
  }

  pushMatrix();




  translate(width/2, height/2, 0);



  for (int i = 0; i &lt; VertCount; i++) {
    //PVector orgv = model.getVertex(i);

    locas[i]= model.getVertex(i);
    Verts[i]= Smodel.getVertex(i);


    //PVector tmpv = new PVector();





    //+4 for 1920*1440
    float randX = noise(randomGaussian())+4;
    float randY = noise(randomGaussian())+4;
    float randZ = noise(randomGaussian())+4;

    PVector Ran = new PVector(randX, randY, randZ);




    Verts[i].x+=Ran.x;
    Verts[i].y+=Ran.y;
    Verts[i].z+=Ran.z;

    if (Verts[i].x &gt; width/2 ) {
      Verts[i].x=-width/2;
    } else if (Verts[i].x &lt; -width/2) {
      Verts[i].x=width/2;
    }
    if (Verts[i].y &gt; height/2 ) {
      Verts[i].y=-height/2;
    } else if (Verts[i].y &lt; -height/2) {
      Verts[i].y=height/2;
    }

    if (Verts[i].z &lt; -width/2 ) {  
      Verts[i].z=800/2;
    } else if ( Verts[i].z &gt; width/2) {
      Verts[i].z=-width/2;
    }


    pushMatrix();
    translate(width/2, height/2, 0);
    rotateY(k);
    tmpmodel.setVertex(i, Verts[i].x, Verts[i].y, Verts[i].z);
    popMatrix();




    if (Kin==true) {
      if ((Verts[i].y &gt; Mouse.y  - r/2 &amp;&amp; Verts[i].y &lt; Mouse.y  + r/2 &amp;&amp; Verts[i].x &gt; Mouse.x  - r/2 &amp;&amp; Verts[i].x &lt; Mouse.x  + r/2 &amp;&amp; Verts[i].z &gt; Mouse.z  - 1225 &amp;&amp; Verts[i].z &lt;  Mouse.z  + 1225)||(Verts[i].y &gt; Mouse2.y  - r/2 &amp;&amp; Verts[i].y &lt; Mouse2.y  + r/2 &amp;&amp; Verts[i].x &gt; Mouse2.x  - r/2 &amp;&amp; Verts[i].x &lt; Mouse2.x  + r/2 &amp;&amp; Verts[i].z &gt; Mouse2.z  - 1225 &amp;&amp; Verts[i].z &lt;  Mouse2.z  + 1225)) {




        pushMatrix();
        rotateY(k);


        tmpmodel.setVertex(i, locas[i].x, locas[i].y, locas[i].z);
        popMatrix();
      }
    }
  }




  rotateY(k);
  noStroke();
  tmpmodel.draw();








  popMatrix();
  if (Text1==true) {

    pushMatrix();
    translate(0, 0, 1255);
    //the hypotenuse

    image(img, 0, 0);

    popMatrix();
  }





  spout.sendTexture();
  //println(Tmeter);
}




void onNewUser(SimpleOpenNI kinect, int userID) {
  kinect.startTrackingSkeleton(userID);
}


void onEndCalibration(int userId, boolean successful) {
  if (successful) {
    println(" User calibrated !!!");
    kinect.startTrackingSkeleton(userId);
  } else {
    println("  Failed to calibrate user !!!");
    kinect.startTrackingSkeleton(userId);
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>john conways game of life</title>
      <link>https://forum.processing.org/two/discussion/18449/john-conways-game-of-life</link>
      <pubDate>Fri, 07 Oct 2016 21:47:31 +0000</pubDate>
      <dc:creator>codez</dc:creator>
      <guid isPermaLink="false">18449@/two/discussions</guid>
      <description><![CDATA[<p>hey i was wondering as to how to make a simple pixel program similar to john conways game of life, i want to make my own particular bit commands were bits react the way i want them and i simply dont know how to develp a simple code to get me working with the enviroment were i can make my own choices on as to how the bits effect each other. maybe somthing like a fibonnacci function of single bits on the screen, like if one bit turns on then, that will turn on another bit, if 2 bits are on that will turn on 3 more etc..</p>
]]></description>
   </item>
   <item>
      <title>Conway Game of Life</title>
      <link>https://forum.processing.org/two/discussion/11408/conway-game-of-life</link>
      <pubDate>Tue, 23 Jun 2015 05:10:09 +0000</pubDate>
      <dc:creator>tsunii</dc:creator>
      <guid isPermaLink="false">11408@/two/discussions</guid>
      <description><![CDATA[<p>Guys, i have a university work that i need to make the this game i found a code somewhere on google, but there's a part that i dont understand</p>

<pre><code>// Birth and death cycle 
for (int x = 0; x &lt; sx; x=x+1) { 
  for (int y = 0; y &lt; sy; y=y+1) { 
    int count = neighbors(x, y); 
    if (count == 3 &amp;&amp; world[x][y][0] == 0) 
    { 
      world[x][y][1] = 1; 
    } 
    if ((count &lt; 2 || count &gt; 3) &amp;&amp; world[x][y][0] == 1) 
    { 
      world[x][y][1] = -1; 
    } 
  } 
} 

// Count the number of adjacent cells 'on' 
int neighbors(int x, int y) 
{ 
  return world[(x + 1) % sx][y][0] + 
  world[x][(y + 1) % sy][0] + 
  world[(x + sx - 1) % sx][y][0] + 
  world[x][(y + sy - 1) % sy][0] + 
  world[(x + 1) % sx][(y + 1) % sy][0] + 
  world[(x + sx - 1) % sx][(y + 1) % sy][0] + 
  world[(x + sx - 1) % sx][(y + sy - 1) % sy][0] + 
  world[(x + 1) % sx][(y + sy - 1) % sy][0]; 
}
</code></pre>

<p>I dont know principaly the "count the number of adjacent cells 'on'. I dont know what that lots of world do, i already tried to comment the parts, i know that it makes the "game" finish early, but i dont know exactly what they do. Could you guys help me? My teacher wants me to comment all the code, but i cant comment that part because i dont understand.</p>
]]></description>
   </item>
   </channel>
</rss>